//
//  AppDelegate.m
//  TreeHole
//
//  Created by apple on 2020/4/11.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "AppDelegate.h"
#import "THHomeViewController.h"
#import "THLoginHomeViewController.h"
@interface AppDelegate ()

@end
//@synthesize window = _window;
@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    
    [BFBaseConfigDataController stoneobs_fun_get_qn_token_handle:^(NSString * _Nonnull qntoken, NSString * _Nonnull headurl) {
        STTools_UserManger.defult.qnToken = qntoken;
        STTools_UserManger.defult.qNhead = headurl;
    }];
    
    ({
        [SVProgressHUD setMinimumDismissTimeInterval:2];
        [SVProgressHUD setMaxSupportedWindowLevel:2];
        [SVProgressHUD showWithStatus:@""];
        [SVProgressHUD dismiss];
        self.window = [[UIWindow alloc] initWithFrame:STONEOBS_UI_UISCREEN_FRAME];
        self.window.backgroundColor = UIColor.whiteColor;
        [self.window makeKeyAndVisible];
        
        THUserModel * user = STTools_UserManger.defult.stoneobs_fun_get_loginedUser;
        if (user.token.length) {
            self.window.rootViewController = STTools_TabbarViewController.new;
        }else{
            RTRootNavigationController *nav = [[RTRootNavigationController alloc] initWithRootViewController:THLoginHomeViewController.new];
            self.window.rootViewController = nav;
        }
    });
    [TMWechatSocietyManger.manger registerWechatWithAppId:WE_CHAT_APPID];
    // Override point for customization after application launch.
    return YES;
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    [[TMAliPayManger manger] inAppDelegateDealOpenURL:url];
    if ([url.description containsString:TMWechatSocietyManger.manger.appId]) {
        return [WXApi handleOpenURL:url delegate:TMWechatSocietyManger.manger];
    }
    return YES;
    
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
    [[TMAliPayManger manger] inAppDelegateDealOpenURL:url];
    if ([url.description containsString:TMWechatSocietyManger.manger.appId]) {
        return [WXApi handleOpenURL:url delegate:TMWechatSocietyManger.manger];
    }
    return YES;
}

@end
